import Http from '@/utils/httpUtil'

const generateId = () => (Math.floor(Math.random() * 10e15)).toString(32)

// 新增组织单元
export const addOrgGroup = param => Http.post(`${'ucenter/orgGroup/add'}?uuId=${generateId()}`, param)

// 获取组织单元全部列表
export const getAllOrgGroupList = param => Http.get('ucenter/orgGroup/all', param)

// 获取组织单元分页列表
export const getOrgGroupList = param => Http.get('ucenter/orgGroup/list', param)

// 根据用户id获取组织单元列表
export const getOrgGroupListByUserId = id => Http.get(`${'ucenter/orgGroup/listByUser'}/${id}`)

// 批量删除组织单元信息
export const deleteOrgGroup = param => Http.post('ucenter/orgGroup/delete', param)

// 编辑组织单元
export const updateOrgGroup = param => Http.post('ucenter/orgGroup/edit', param)

// 根据id获取组织单元详情
export const findOneByOrgGroupId = param => Http.get(`${'ucenter/orgGroup/info'}/${param}`)

// 获取组织单元树
export const getOrgGroupTreeList = param => Http.get('ucenter/orgGroup/tree', param)

// 获取组织单元分层数据
export const listOrgGroupByParentId = param => Http.get('ucenter/orgGroup/listOrgByParentId', param)
